import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import styleImport, { VantResolve } from "vite-plugin-style-import";
import { svgstore } from "./src/vite_plugins/svgstore.js";
// @ts-nocheck

// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
  return {
    define:
      command === "build"
        ? {
            DEBUG: false,
          }
        : {
            DEBUG: true,
          },
    base: "https://fruit-account-1317770777.cos.ap-shanghai.myqcloud.com",
    build: {
      rollupOptions: {
        output: {
          manualChunks(id: any) {
            if (id.includes("echarts")) {
              return "echarts";
            }
            if (id.includes("mock") || id.includes("faker")) {
              return "mock";
            }
            if (id.includes("vant")) {
              return "vant";
            }
            if (id.includes("node_modules")) {
              return "vendor";
            }
          },
        },
      },
    },
    plugins: [
      vue(),
      vueJsx({
        transformOn: true,
        mergeProps: true,
      }),
      svgstore(),
      styleImport({
        resolves: [VantResolve()],
      }),
    ],
    server: {
      proxy: {
        "/api/v1": { target: "https://mangosteen2.hunger-valley.com" },
      },
    },
  };
});
